﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SocialIn.Biz;
using System.Text;

namespace SocialIn.Web.UserControls
{
    public partial class UCTalent : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CommonData common = new CommonData();

                DataTable result = common.GetCodeMaster("M003").ReturnValue;

                this.ltrTalent.Text = GenHtml(result);
            }
        }

        private string GenHtml(DataTable data)
        {
            StringBuilder html = new StringBuilder(@"<table>");
            foreach (DataRow item in data.Rows)
            {
                html.Append("<tr>");

                html.AppendFormat("<td>{0}</td>", item["CodeName"]);

                html.AppendFormat("<img alt='' src='{0}' />"
                                , VirtualPathUtility.ToAbsolute(item["Etc1"].ToString()));

                html.AppendFormat("<td>{0}</td>", item["Etc2"]);

                html.Append("</tr>");
            }

            html.Append("</table>");

            return html.ToString();
        }
    }
}